#include <QDebug>
#include <QMessageBox>
#include "SelectThemeName.h"
#include "ui_SelectThemeName.h"
#include "Include/Settings.h"

SelectThemeName::SelectThemeName(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::SelectThemeName)
{
    ui->setupUi(this);
    connect(ui->buttonBox, SIGNAL(accepted()), SLOT(onAccept()));
}

SelectThemeName::~SelectThemeName()
{
    delete ui;
}

QString SelectThemeName::name()
{
    return ui->edtThemeName->text();
}

void SelectThemeName::onAccept()
{
    ITheme * theme = Plugins::Settings::instance()->themeByName(ui->edtThemeName->text());
    if (theme){
        QMessageBox::critical(this, tr("File exists"), tr("Theme with such name already exists"));
        return;
    }
    accept();
}
